<html>
<head><%String docURL = (String) request.getAttribute("link");
String rid = (String) request.getAttribute("resid");
if (docURL.length()>0) {
%>
    <link rel="stylesheet" href="css/dashboard.css" type="text/css" />
    <script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript">
	    $(function(){
            $("#flash").show();
		    loadsheet();
	    });
	    
	    function loadsheet() {
	        var params = "resid=<%=rid.toString()%>";
	        $.ajax({
	            type: "GET",
	            url: "check",
	            data: params,
	            cache: false,
	            success: function(html){
	        	   if (html=="true") {
	        		   window.location.replace("<%=docURL.toString()%>");
	        	   } else if (html=="first") {
	        		   setTimeout('window.location.replace("<%=docURL.toString()%>")', 15000);
	        	   } else {
	        		   loadsheet();
	        	   }
	            }
	        });
	    }    
	</script>
</head><body>
<div id="flash" align="left"  ><img src="images/ajax-loader.gif" align="absmiddle">&nbsp;<span class="loading">Loading...</span></div>
</body><%
} else {
%></head>
<body>
    <script type="text/javascript">
        //window.opener="something";
        window.close();
    </script>
</body><%
}%>
</html>